Two small tweaks for cross compiling #208
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Two more tiny tweaks that will smoothen the cross compile process:
First the
arch
detection in libtbb relies on/usr/sbin/sysctl
which does not work on linux or macos-cross. As a result it ends up falling back onarch=ia32
which is completely wrong.RcppParallel/src/tbb/build/macos.inc
Lines 30 to 50 in d4573c1
The robust way to detect the target arch on Mac is
uname -m
(the cross environments shimuname
to return the target). So we pre-set that in the RcppParallel Makevars, the same way as is done for Windows.And one final tweak: we introduce a variable
TBB_LINK_LIB
that we can use to set the location of the target libtbb, without affecting the runtime TBB. If the variable is unset, the current behavior remains the same.This is needed, because when we cross compile packages that link against RcppParallel, we need have two copies of RcppParallel: one on the host architecture, that is use to load RcppParallel in order to call
RcppParallel::RcppParallelLibs()
. And then we need a separate installation of RcppParallel for the cross target architecture, that the package we are building should link against.Currently we have no way of doing this: if we set
TBB_LIB
to the cross target arch, the RcppParallel won't load, but if we set it to the host (or we leave it undefined) the path returned byRcppParallel::RcppParallelLibs()
returns the host architecture and gives a linking error for the cross build.